package com.bangdream.michelia.model;

import com.alibaba.fastjson.JSON;
import com.bangdream.michelia.application.AppCurrentUser;
import com.bangdream.michelia.contract.MessageContract;
import com.bangdream.michelia.tool.retrofithttp.RetroFactory;
import com.bangdream.michelia.utils.L;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * @date on 2018/8/12 17:52
 * @email 909732184@qq.com
 * 站内消息
 */
public class IMessageModelImpl implements MessageContract.ICoursesModel {
    @Override
    public Observable getUserMessageList(Map<Object, Object> paramsMap) {
        String jsonString = JSON.toJSONString(paramsMap);
        L.d(jsonString);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),jsonString);
        String stTokent = AppCurrentUser.getInstance().getToken();
        return RetroFactory.getInstance().getStationUserMessageList(stTokent,requestBody);
    }

    @Override
    public Observable getSystemMessageList(Map<Object, Object> paramsMap) {
        String jsonString = JSON.toJSONString(paramsMap);
        L.d(jsonString);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),jsonString);
        String stTokent = AppCurrentUser.getInstance().getToken();
        return RetroFactory.getInstance().getStationMessageList(stTokent,requestBody);
    }

    @Override
    public Observable actionRead(String id) {
        String stTokent = AppCurrentUser.getInstance().getToken();
        return RetroFactory.getInstance().updateUserMessageReadFlag(stTokent,id);
    }
}
